package com.atguigu.rabbitmq.six;
import com.atguigu.rabbitmq.util.RabbitMqUtils;
import com.rabbitmq.client.Channel;

import java.io.IOException;
import java.util.Scanner;
import java.util.concurrent.TimeoutException;
// p44
/**
 * 直接交换机
 */
public class DirectLog {

    public static final String EXCHANGE_NAME = "direct_logs";


    public static void main(String[] args) throws IOException, TimeoutException {

        Channel channel = RabbitMqUtils.getChanner();

        Scanner scanner = new Scanner(System.in);

        while (scanner.hasNext()) {
            String message = scanner.next();
            //想让哪个队列接收,routingKey就填哪个
            channel.basicPublish(EXCHANGE_NAME, "info", null, message.getBytes("UTF-8"));
            System.out.println("生产者发出消息:" + message);
        }

    }

}